package exam.meituan.T4;


import java.util.Scanner;

public class Main {

    public static long resNum = 0;
    public static int maxSum = Integer.MIN_VALUE;
    public static int n = 0;
    public static int k1 = 0;
    public static int k2 = 0;
    public static int[] nums;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k1 = sc.nextInt();
        k2 = sc.nextInt();
        nums = new int[n];
        for (int i=0; i<n; ++i) {
            nums[i] = sc.nextInt();
        }
        dfs(0, 0);
        System.out.println(maxSum + " " + resNum % 998244353);
    }

    public static void dfs(int cur, int sum) {
        if (cur == n) {
            if (valid(sum)) {
                if (sum > maxSum) {
                    resNum = 1L;
                    maxSum = sum;
                } else {
                    resNum++;
                }
            }
            return;
        }
        dfs(cur+1, sum);
        dfs(cur+1, sum + nums[cur]);
    }

    public static boolean valid(int sum) {
        if (sum % k1 == 0 && sum % k2 != 0)
            return true;
        return false;
    }
}
